cbuffer cbPerObject
{
	float4x4 WorldViewProjection;	
	float4x4 WorldView;	
	float4x4 View;	
	float4x4 InverseProjection;
}

cbuffer cbGlobal
{
	int2 inputSize;
}

SamplerState HdrSampler
{
	Filter = MIN_MAG_MIP_POINT;
    AddressU = Clamp;
    AddressV = Clamp;
};

Texture2D hdrTexture;

struct App2VS
{
	float3 pos : POSITION;
	float3 col : COLOR;
	float3 normal : NORMAL;
};
struct VS2PS
{
	float4 pos : SV_Position;
};
struct PS2GPU
{
	float4 value : SV_Target0;
};


void vs(App2VS IN, out VS2PS OUT)
{
	OUT.pos = float4(IN.pos, 1); //pass through for quad/etc
	//get the viewspace viewray
}
void ps(VS2PS IN, out PS2GPU OUT)
{
	float2 uv = IN.pos / inputSize;
	float4 hdrValue = hdrTexture.Sample(HdrSampler, uv);

	float4 total = 0;
	float offset = 0.01;
	[unroll]
	for(int du = -4; du < 4; du++)
	{
		[unroll]
		for(int dv = -4; dv < 4; dv++)
		{				
			total += hdrTexture.Sample(HdrSampler, uv + float2(du * offset, dv * offset));
		}
	}
	
	OUT.value = saturate(hdrValue);
	//OUT.value = total / 81;
}

technique10 Render
{
	pass P0
	{
		SetGeometryShader( 0 );
		SetVertexShader( CompileShader( vs_4_0, vs() ) );
		SetPixelShader( CompileShader( ps_4_0, ps() ) );
	}
}